{% load staticfiles %}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>{% block title %}{% endblock %}</title>
    {# 用CSS来美化一下界面 #}
    <link rel="stylesheet" href="{% static 'base.css' %}">

    {# 引用bootstrap的CSS文件和JS文件 #}
    <link rel="stylesheet" href="{% static 'bootstrap-3.3.7/css/bootstrap.min.css' %}">
    <script type="text/javascript" src="{% static 'jquery-1.12.4.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'bootstrap-3.3.7/js/bootstrap.min.js' %}"></script>

    {# 扩展的文件引用CSS文件 #}
    {% block header_extends %}{% endblock %}
</head>
<body>
    <div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        <div class="container">
            <div class="navbar-header left">
                <div class="logo"><a class="navbar-brand logo ttop" href="/">Byack-笔记</a></div>
                <button class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
            </div>
            <div id="navbar-collapse" class="collapse navbar-collapse">
                <ul class="nav navbar-nav ttop">
                    <li class="{% block nav_home_active %}{% endblock %}">
                        <a class="ttop" href="/"><span class="glyphicon glyphicon-home"></span></a>
                    </li>
                    <li class="{% block nav_blog_active %}{% endblock %}">
                        <a class="ttop" href="{% url 'blog_list' %}">博客列表</a>
                    </li>
                </ul>
                <ul class="nav navbar-nav navbar-right">
                    {% if user.is_authenticated %}
                        <li class="dropdown ttop">
                            <a href="#" class="dropdown-toggle ttop" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                                {% if user.has_nickname %}
                                    {{ user.username }}({{ user.get_nickname }})
                                {% else %}
                                    {{ user.username }}
                                {% endif %}
                                <span class="caret"></span>
                            </a>
                            <ul class="dropdown-menu">
                                <li><a href="{% url 'user_info' %}">个人信息</a></li>
                                <li role="separator" class="divider"></li>
                                <li><a href="{% url 'change_nickname' %}?from={{ request.get_full_path }}">修改昵称</a></li>
                                <li role="separator" class="divider"></li>
                                <li><a href="{% url 'change_password' %}">修改密码</a></li>
                                <li role="separator" class="divider"></li>
                                <li><a href="{% url 'logout' %}?from={{ request.get_full_path }}">注销账户</a></li>
                                {% if user.is_staff or user.is_superuser %}
                                    <li role="separator" class="divider"></li>
                                    <li><a href="{% url 'admin:index' %}"><span class="glyphicon glyphicon-modal-window"></span></a></li>
                                {% endif %}
                            </ul>
                        </li>
                    {% else %}
                        <li class="ttop"><a class="ttop" href="{% url 'login' %}?from=home">登录</a></li>
                        <li class="ttop"><a class="ttop" href="{% url 'register' %}?from=home">注册</a></li>
                    {% endif %}
                </ul>
            </div>
        </div>
    </div>
    {% block content %}{% endblock %}
    {% block script_extends %}{% endblock %}
</body>
</html>
